package edu.suse.controller;


import edu.suse.common.base.RespResult;
import edu.suse.entity.Collection;
import edu.suse.service.CollectionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/collection")
@Slf4j
public class CollectionController {

    @Autowired
    private CollectionService collectionService;

    // 查询页码
    @GetMapping("/getCollectionList")
    public RespResult getCollectionList(Integer pageSize){
        return collectionService.getCollectionList(pageSize);
    }
    // 分页查询
    @GetMapping("/findCollectionAll")
    public RespResult findCollectionAll(Integer currentPage,Integer pageSize){
        return collectionService.findCollectionAll(currentPage,pageSize);
    }
    // 朝代查询
    @GetMapping("/dynastyCollection")
    public RespResult dynastyCollection(){
        return collectionService.dynastyCollection();
    }
    // 升序
    @GetMapping("/ascSort")
    public RespResult ascSort(){
        return collectionService.ascSort();
    }
    // 朝代查询
    @GetMapping("/dynastyCollevtionAll")
    public RespResult dynastyCollevtionAll(String command){
        return collectionService.dynastyCollevtionAll(command);
    }


    // 添加文物信息
    @PostMapping("/addCollectionAll")
    public RespResult addCollectionAll(@RequestBody Collection addList){
        log.info("传入的参数是",addList);
        return collectionService.addCollectionAll(addList);
    }

    // 删除文物信息
    @GetMapping("/deleteCollection")
    public RespResult deleteCollection(String id){
        return collectionService.deleteCollection(id);
    }
    // 查找文物信息
    @GetMapping("/findCollectionById")
    public RespResult findCollectionById(String id){
        return collectionService.findCollectionById(id);
    }
    // 模糊查找文物信息
    @GetMapping("/searchCollection")
    public RespResult searchCollection(String searchCollection){
        log.info("传入的参数是",searchCollection);
        System.out.println("传入的参数是"+searchCollection);
        return collectionService.searchCollection(searchCollection);
    }

    // 修改文物信息
    @PostMapping("/editCollection")
    public RespResult editCollectionAll(@RequestBody Collection editList){
        log.info("传入的参数是",editList);
        return collectionService.editCollection(editList);
    }
}
